{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<style>
    .tishi{
        color: #5cb85c;
        position: absolute;
        z-index: 5;
        left: 550px;
        width: 100%;
        top: 5px;
        font-size: 14px;
    }
    .checkbox{
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .checkbox label{
         width: 120px;
    }

</style>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post"
                      enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">字段选择</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="checkbox">

                                        {foreach name="fields" key="key" item="vo"}
                                    <label>
                                        <input type="checkbox" {if isset($field) && in_array($key,$field)}checked{/if} value="{$key}" name="checkbox[]" class="field-checkbox"><p>{$vo}</p>
                                    </label>
                                        {/foreach}

                                </div>
                            </div>
                        </div>

                    </div>



                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'name': {
                required: true,
            },
            'department_id': {
                required: true,
            },
            'position_id': {
                required: true,
            },
            'job_number': {

            },
            'mobile': {
                required: true,
            },
            'email': {
                required: true,
            },
            'birthday': {
                required: true,
            },
            'hired_date': {
                required: true,
            },
            'insurance': {
                required: true,
            },
            'is_leader': {
                required: true,
            },
            'sort_number': {
                required: true,
            },

        },
        messages: {
            'name': {
                required: "姓名不能为空",
            },
            'department_id': {
                required: "部门不能为空",
            },
            'position_id': {
                required: "职位不能为空",
            },
            'job_number': {

            },
            'mobile': {
                required: "手机号不能为空",
            },
            'email': {
                required: "邮箱不能为空",
            },
            'birthday': {
                required: "生日不能为空",
            },
            'hired_date': {
                required: "入职日期不能为空",
            },
            'insurance': {
                required: "保险种类不能为空",
            },
            'is_leader': {
                required: "是否所属部门领导不能为空",
            },
            'sort_number': {
                required: "排序不能为空",
            },

        }
    });
</script>
{/block}